﻿using UnityEngine;

public class AutoHide : MonoBehaviour 
{
    public float delay = 1f;

	private double _lastShowTime = -1;

	public void OnEnable()
	{
		_lastShowTime = Time.realtimeSinceStartup;
	}

    public void Show()
    {
        gameObject.SetActive(true);

		_lastShowTime = Time.realtimeSinceStartup;
    }
	
    public void Update()
    {
		if (_lastShowTime > 0 && Time.realtimeSinceStartup - _lastShowTime >= delay)
	    {
		    _lastShowTime = -1;
		    gameObject.SetActive(false);
	    }
    }
}
